package uicgas.pump;

import uicgas.globaldata.CreditCard;
import uicgas.globaldata.States;
import uicgas.globaldata.Transaction;
import uicgas.globaldevice.SwipeCardNotifiable;
import uicgas.pump.device.PhysicalPump.GasolineGrade;

/**
 * PumpLogic connected to the Pump, and perform all the business logic of pump.<br>
 * Also PumpLogic controls Communication Module to send/receive message between itself
 * and Server Station
 * 
 * @author Hong Wang
 *
 */
public interface PumpLogic extends SwipeCardNotifiable
{
	/**
	 * Activates the pump. <br>
	 * The pump has been prepaid and 
	 * is waiting for the	motorist to select grade and start pumping.
	 * @param card Credit card infomation
	 */
	void activatePump(CreditCard card);

	/**
	 * Deactivates the pump. <br>
	 * The pump is on and waiting for a card swipe 
	 * or signal from the register that someone has prepaid inside.
	 */
	void deactivatePump();

	/**
	 * Control pump begin pumping the gasoline
	 */
	void beginToPump();

	/**
	 * Control pump stop pumping
	 */
	void finishPumping();

	/**
	 * Prints the receipt for current transaction at the pump side.
	 * 
	 * @return if true printed successful; if false printed failed
	 */
	boolean printReceipt();

	/**
	 * Send request for operator's assistance to the Server Station
	 */
	void callForAssistance();

	/**
	 * Return the unique ID for this pump. 
	 * The Id should between 0~19.
	 * 
	 * @return unique ID for this pump
	 */
	int getID();

	/**
	 * When the ID has been used in the Server Station side, Server may ask pump 
	 * re-generate a new one for its ID. <br>
	 * This method let pump generate a new ID, 
	 * and store it in pump for future inquiry.
	 */
	void generateNewID();

	/**
	 * Change pump's state, and return original state of this pump 
	 * 
	 * @param newState new state changing to, 
	 * can be one of them {@link States#ACTIVATED}, {@link States#DEACTIVATED}, {@link States#DECOMMISSIONED}
	 * 
	 * @return original state of this pump 
	 */
	States changeState(States newState);

	/**
	 * Return current state of this pump 
	 * 
	 * @return current state of this pump<br>
	 * can be one of them {@link States#ACTIVATED}, {@link States#DEACTIVATED}, {@link States#DECOMMISSIONED}
	 */
	States getCurrentState();

	/**
	 * Change the gasoline grade for pumping
	 * 
	 * @param grade
	 */
	void changeGrade(GasolineGrade grade);

	/**
	 * Takes the pump out of service.
	 */
	void decommissionPump();

	/**
	 * Put the pump back into service.
	 */
	void recommissionPump();

	/**
	 * Return current transaction information in the pump
	 * 
	 * @return current transaction information
	 */
	Transaction getCurrentTransaction();

	void cardInvalid();

	void setShowingID(int id);

}
